package com.will.txj.aj.security.filter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;

/**
 * @author: wen-yi;
 * @date: 2021/12/5 11:09;
 * @Description: 过滤器配置
 */
@Configuration
public class FilterConfig {
    @Autowired
    private CharacterFilter characterFilter;

    @Bean
    @Order(0)     //spring boot会按照order值的大小，从小到大的顺序来依次过滤
    public FilterRegistrationBean configFilter(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(characterFilter);
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.setName("characterFilter");
        //filterRegistrationBean.setOrder(2);
        return filterRegistrationBean;
    }
}
